package com.qtyx.nms.ui.adapter

import android.content.Context
import android.content.Intent
import android.os.Parcelable
import android.view.View
import android.widget.LinearLayout
import android.widget.TextView
import com.ldd.base.ui.adapter.BaseRVAdapter
import com.ldd.base.ui.adapter.BaseRVVH
import com.qtyx.nms.R
import com.qtyx.nms.mvp.model.bean.MessageBean
import com.qtyx.nms.ui.activity.MessageListActivity
import com.qtyx.nms.util.IntentKey

/**
 * 消息适配器
 */
class HomePageMessageAdapter(mContext: Context, list: List<MessageBean.Data>) :BaseRVAdapter<MessageBean.Data>(mContext, list) {

    override fun getLayoutId(viewType: Int)= R.layout.item_homepage_message


    override fun convert(vh: BaseRVVH, position: Int, data: MessageBean.Data) {
        val llMain=vh.getView<LinearLayout>(R.id.ll_item_homepage_message_main)
        val tvTitle=vh.getView<TextView>(R.id.tv_item_homepage_message_title)
        val tvDate=vh.getView<TextView>(R.id.tv_item_homepage_message_date)
        val viewState=vh.getView<View>(R.id.view_item_homepage_message_read_state)

        tvTitle.text=data.noticeHead
        tvDate.text=data.createTime

        if(0==data.readType){
            viewState.visibility= View.VISIBLE
        }else{
            viewState.visibility= View.INVISIBLE
        }

        llMain.setOnClickListener {
            onItemClickListener?.onItemClick(position,data)
        }
    }

    var onItemClickListener: OnItemClickListener? = null

    interface OnItemClickListener {
        fun onItemClick(position: Int,data: MessageBean.Data)
    }

}